package com.prs.crm.domain.sale;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.FlowEntity;
import com.prs.crm.domain.store.StoreRoom;

@Entity
@Table(name = "sale_salesStoreOut")
public class SalesStoreOut extends FlowEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	private String salesStoreOutName;

	/**
	 * 关联发货单
	 * 
	 */
	@ManyToOne
	private SalesShipping salesShipping;

	/**
	 * 出库库房
	 */
	@ManyToOne
	private StoreRoom storeRoom;

	/**
	 * 出库时间
	 */
	private Date outDate;

	/**
	 * 出库明细
	 */
	@OneToMany(mappedBy = "salesStoreOut")
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<SalesStoreOutDetail> details;
	/**
	 * 
	 */
	@Lob
	private String reamrk;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public SalesShipping getSalesShipping() {
		return salesShipping;
	}

	public void setSalesShipping(SalesShipping salesShipping) {
		this.salesShipping = salesShipping;
	}

	public StoreRoom getStoreRoom() {
		return storeRoom;
	}

	public void setStoreRoom(StoreRoom storeRoom) {
		this.storeRoom = storeRoom;
	}

	public Date getOutDate() {
		return outDate;
	}

	public void setOutDate(Date outDate) {
		this.outDate = outDate;
	}

	public Set<SalesStoreOutDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<SalesStoreOutDetail> details) {
		this.details = details;
	}

	public String getSalesStoreOutName() {
		return salesStoreOutName;
	}

	public void setSalesStoreOutName(String salesStoreOutName) {
		this.salesStoreOutName = salesStoreOutName;
	}

	public String getReamrk() {
		return reamrk;
	}

	public void setReamrk(String reamrk) {
		this.reamrk = reamrk;
	}

	public void addDetail(SalesStoreOutDetail detail) {
		if (details == null)
			details = new HashSet<SalesStoreOutDetail>();
		detail.setSalesStoreOut(this);
		details.add(detail);
	}

}
